/* eslint-disable */ 
'use strict';

const Controller = require('egg').Controller;

class MockController extends Controller {
  async login() {
    const { ctx } = this;
    console.log({ loginParams: ctx.request.body });
    const { username } = ctx.request.body;
    const { status, message } = await ctx.service.mock.index(username);
    if (status) {
      ctx.body = {
        code: 0,
        message,
      };
    } else {
    //   this.ctx.status = 400;
      ctx.body = {
        code: 1,
        message,
      };
    }


  }

  async getUser() {
    const { ctx } = this;
    console.log({ requestParams: ctx.request.query });
    const result = await ctx.service.mock.userInfo();
    // this.ctx.status = 400;
    ctx.body = {
      code: 0,
      message: 'success',
      data: result,
    };
  }


  async mockGet() {
    const { ctx } = this;
    console.log({ header: ctx.request });
    const s = await ctx.service.mock.checkSign()
    console.log({ backend: s })
    ctx.body = {
      code: 0,
      message: 'success',
      data: {
        s
      },
    };
  }

  async mockPost() {
    const { ctx } = this;
    console.log({ body: ctx.request });
    const s = await ctx.service.mock.checkSign()
    ctx.body = {
      code: 0,
      message: 'success',
      data: {
        msg: "模拟成功 mockPost",
        s
      },
    };
  }


}

module.exports = MockController;
